import React from 'react';
import { Button, Icon } from 'antd';
import { connect } from 'dva';
// import router from 'umi/router';
import Dialog from '@/components/Dialog';
import Notice from '@/components/Notice';
// import Link from 'umi/link'
import settings from '@/settings';

export default connect(({ app: { user } }) => ({
  user
}))(props => {
  const { user = {}, dispatch } = props;
  const handleQuit = e => {
    Dialog.confirm({
      title: '确认操作',
      content: '确定要退出登录吗？',
      onOk() {
        dispatch({
          type: 'app/logout',
        });
      },
    });
  };
  const { title } = settings;
  return (
    <div className="header">
      <div className="header-toolbar">
        <div className="fl tools">
          <ul>
            <li>
              <span className="ico-button">{title}</span>
            </li>
          </ul>
        </div>
        <div className="fr tools">
          <ul>
            {/*<li><Link to="/login"><Icon type="poweroff" /> <span>退出</span></Link></li>*/}
            <li>
              {/*<Badge count={1000}>
                <Icon type="notification" />
              </Badge>*/}
              <Notice
                count={1000}
                >
                <Notice.Tab
                  title="通知"
                  data={[{
                    id: 1,
                    text: '您收到了14份新周报'
                  }, {
                    id: 2,
                    text: '内容不要超过两行字，超出时自动截断'
                  }]}
                  >
                </Notice.Tab>
                <Notice.Tab
                  title="代办"
                  data={[{
                    id: 1,
                    text: '这是一条测试数据'
                  }, {
                    id: 2,
                    text: '第三方紧急代码变更'
                  }]}
                  >
                </Notice.Tab>
              </Notice>
            </li>
            <li>
              <Icon type="user" /> <span>{user.name}</span>
            </li>
            <li>
              <Button type="link" icon="poweroff" onClick={handleQuit}>
                退出
              </Button>
            </li>
          </ul>
        </div>
      </div>
    </div>
  );
});
